#include "line.h"
#include <iostream>
using namespace std;

class Line::LineImpl{
public:
    LineImpl(int x1,int y1,int x2,int y2)
        :_pt1(x1,y1)
         ,_pt2(x2,y2)
    {
        cout << "LineImpl(int,int,int,int)"<<endl;
    }
    void printLine(){
        _pt1.print();
        cout << "------" ;
        _pt2.print();
        cout << endl;
    }

private:
    class Point{
    public:
        Point(int x,int y)
        :_x(x)
         ,_y(y)
        {
            cout << "Point(int,int)" << endl;
        }
        void print(){
            cout << _x << "," << _y;
        }
    private:
        int _x;
        int _y;
    };

    Point _pt1;
    Point _pt2;
};

Line::Line(int x1, int y1, int x2, int y2)
    :_impl(new LineImpl(x1,y1,x2,y2))
{
    cout << "Line(int,int,int,int)" << endl;
}

Line::~Line(){
    if(_impl){
        delete _impl;
        _impl = nullptr;
    }
}

void Line::printLine(){
    _impl->printLine();
}
